/**
 * 
 */
package org.swing.utility.system.log;

import java.io.IOException;
import java.io.InputStream;

import org.swing.utility.system.stream.StreamUtils;

/**
 * @author lqnhu
 *
 */
public class ErrorReader extends Thread {
	private InputStream err;
	private String error = null;

	public ErrorReader(InputStream err) {
		this.err = err;
	}

	public void run() {
		try {
			error = StreamUtils.readInputStream(err);
		} catch (IOException e) {
			error = "";
			notifyAll();
		}
	}

	public String getError() {
		return error;
	}

	public void waitFor() {
		while (error == null) {
			synchronized (this) {
				try {
					wait(500);
				} catch (InterruptedException e) {
				}
			}
		}
	}
}
